package com.gutai.admin.common.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * 
 * 注册拦截器
 * 
 * <pre>
 * HISTORY
 * ****************************************************************************
 *  ID    DATE            PERSON            REASON
 *  1     2019年1月25日         la.01367604           Create
 * ****************************************************************************
 * </pre>
 * 
 * @author la.01367604
 * @version 1.0
 */
@SpringBootConfiguration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private HandlerInterceptor reqAuthInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册拦截器
        InterceptorRegistration loginRegistry = registry.addInterceptor(reqAuthInterceptor);
        // 拦截路径
        loginRegistry.addPathPatterns("/**");

        // // 排除路径
        // loginRegistry.excludePathPatterns("/");
        // loginRegistry.excludePathPatterns("/login");
        // loginRegistry.excludePathPatterns("/loginout");
        // // 排除资源请求
        // loginRegistry.excludePathPatterns("/css/login/*.css");
        // loginRegistry.excludePathPatterns("/js/login/**/*.js");
        // loginRegistry.excludePathPatterns("/image/login/*.png");
    }
}
